#pragma once

#include <Totem/HashedString.h>
#include <glm/glm.hpp>
#include <libtcod/libtcod.hpp>
#include <vector>
#include <memory>
#include <string>
#include <stack>

namespace Views
{
	class IView;
	class ViewManager
	{
	public:
		ViewManager(const std::string &resource_dir, const std::string &title, const glm::ivec2 &viewport, unsigned int alignment);
		~ViewManager();

		void update(float dt);
		void render();

		void add(const std::string &view_file);
		void pushActive(Totem::HashedString1 view_id);
		void pushActiveGui(Totem::HashedString1 view_id);
		void popActive();
		void popActiveGui();

	public:
		void inputKeyDown(TCOD_key_t &key, TCOD_mouse_t &mouse);
		void inputKeyUp(TCOD_key_t &key, TCOD_mouse_t &mouse);
		void motion(TCOD_key_t &key, TCOD_mouse_t &mouse);
		void mousePressed(TCOD_key_t &key, TCOD_mouse_t &mouse);
		void mouseReleased(TCOD_key_t &key, TCOD_mouse_t &mouse);

	private:
		std::string resource_dir;
		std::vector<std::unique_ptr<IView>> views;
		std::stack<IView*> active_view;
		std::stack<IView*> active_gui_view;
	};
}
